#!/bin/sh
. /etc/utils.sh

case "$1" in
  start)
    # Avoid UDP packet loss by increasing socket buffer size.
    # rmem_max defines the maximum receive socket buffer size in bytes.
    # The actual buffer size is set in sagesrv.
    sysctl net.core.rmem_max=5242880
    # Set the socket write buffer size large enough to hold a complete
    # blocksize from the streamer.
    # wmem_max defines the maximum send socket buffer size in bytes.
    sysctl net.core.wmem_max=1572864
    # Don't delete secondary addresses on an interface when deleting primary
    # addresses. Fixes b/33548012.
    sysctl net.ipv4.conf.default.promote_secondaries=1
    sysctl net.ipv4.conf.all.promote_secondaries=1
    # Panic everytime there is a kernel oops
    sysctl -q kernel.panic_on_oops=1
    # Allow 120 seconds to write a core file out to flash.
    # /bin/coredump gives up after 100 seconds.
    sysctl -w kernel.hung_task_timeout_secs=120
    ;;
  stop)
    ;;
  restart|reload)
    $0 stop; $0 start ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
esac
